﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace CodeEditorCompiler
{
    internal sealed class FeedbackWriter : TextWriter
    {
        private RichTextBox TextCtrl;
        internal FeedbackWriter( RichTextBox textCtrl )
            : base()
        {
            TextCtrl = textCtrl;
        }

        public override Encoding Encoding
        {
            get { return Encoding.Default; }
        }

        public override void Write( string value )
        {
            TextCtrl.AppendText( value.Replace( "\n", base.NewLine ) );
        }

        public override void WriteLine( string value )
        {
            this.Write( value );
            TextCtrl.AppendText( base.NewLine );
        }
    }
}
